package models


import (
	"github.com/astaxie/beego/orm"
	_ "github.com/go-sql-driver/mysql"
	"time"
)

//管理员
type User struct {
	Id int
	Name string
	Pwd string
}

//用户
type UserManage struct {
	UserId string `orm:"pk"`
	UserName string
	RegistTime time.Time `orm:"auto_now add"`
	DueTime time.Time
}



//设备
type DevManage struct {
	DevId int `orm:"pk"`
	DevName string
	AddDevTime time.Time `orm:"auto_now add"`
	ChanManages []*ChanManage `orm:"reverse(many)"`
}

type ChanManage struct {
	ChanId string `orm:"pk"`
	ChanName string
	AddChanTime time.Time `orm:"auto_now add"`
	DevManage *DevManage `orm:"rel(fk)"`
}









func init()  {
	//设置数据基本信息
	orm.RegisterDataBase("default","mysql","root:root@tcp(127.0.0.1:3306)/qy2?charset=utf8&loc=Local")
	//映射model数据
	orm.RegisterModel(new(User),new(UserManage),new(DevManage),new(ChanManage))
	//生成表
	orm.RunSyncdb("default",false,true)
}